package com.boot.mgt.service.impl

import com.alibaba.fastjson.JSON
import com.alibaba.fastjson.JSONObject
import com.boot.core.protocol.*
import com.boot.core.result.ResultTo
import com.boot.mgt.controller.LoginController
import com.boot.mgt.controller.accident.StatisticsController
import com.boot.mgt.controller.app.*
import com.boot.mgt.controller.web.RoadRepairController
import com.boot.mgt.controller.web.TaAccidentReportController
import com.boot.mgt.controller.web.TaPoliceController
import com.boot.mgt.controller.web.vo.TaPoliceVo
import com.boot.mgt.model.*
import com.boot.mgt.service.JsonRpcService
import com.googlecode.jsonrpc4j.JsonRpcParam
import com.googlecode.jsonrpc4j.spring.AutoJsonRpcServiceImpl
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service
import java.util.*

@Service
@AutoJsonRpcServiceImpl
class JsonRpcServiceImpl(
        private var taAppAccidentReportController: TaAppAccidentReportController,
        private var taAccidentReportController: TaAccidentReportController,
        private var taAppAccidentController: TaAppAccidentController,
        private var loginController: LoginController,
        private var taPoliceController: TaPoliceController,
        private var roadRepairController: RoadRepairController,
        private var taAppAccidentStatisticsController: TaAppAccidentStatisticsController,
        private var statisticsController: StatisticsController,
        private var taAppExceptionMsgController: TaAppExceptionMsgController,
        private var taLocationReportController: TaLocationReportController,
        private var taAccidentImageController: TaAccidentImageController,
        private var taHmsPushController: TaHmsPushController
): JsonRpcService {

    override fun connect(queryReqBean: ConnRequestOfApp.ConnParamsOfApp.Data?, sign: String?): Any? {
        var jsonString = JSONObject.toJSONString(queryReqBean)
        log.info("JSON-RPC 2.0 === connect String Information, jsonString ---------- \n{}", jsonString)

        var jsonStringChange: String? = jsonString?.split("\",\"stream")?.get(0)
        log.info("jsonStringChange === \n{}", jsonStringChange)
        val jsonStr: JSONObject? = JSONObject.parseObject(jsonStringChange)
//        val jsonStr: JSONObject? = JSONObject.parseObject(jsonString)
        val methodType: String? = jsonStr?.get("method") as String
        var sign: String? = "awq12m678"

        log.info("JSON-RPC 2.0 === connect get Connections ---------- start")
        val connRequestOfApp: ConnRequestOfApp = JSONObject.parseObject("", ConnRequestOfApp::class.java)
        var dataRequest: ConnRequestOfApp.ConnParamsOfApp.Data? = connRequestOfApp.params?.data
        var connResponseForApp: ConnResponseForApp = ConnResponseForApp()
        var data: ConnResponseForApp.ConnectResultForApp.Data? = ConnResponseForApp.ConnectResultForApp.Data("f534ceba2920499d9511ddd1055e8196", "4b4127fc3b9a4035be3159c3caa7a85e", dataRequest?.timestamp, dataRequest?.nonce)
        var result: ConnResponseForApp.ConnectResultForApp = ConnResponseForApp.ConnectResultForApp(data, 1, "OK", "sign")
        connResponseForApp.jsonrpc = connRequestOfApp.jsonrpc
        connResponseForApp.id = connRequestOfApp.id.toString()
        connResponseForApp.result = result
        log.info("JSON-RPC 2.0 === connect get Connections return result ---------- \n {}", JSON.toJSONString(connResponseForApp))
        log.info("JSON-RPC 2.0 === connect get Connections return result2 ---------- \n {}", JSON.toJSONString(connResponseForApp)?.split("\",\"stream")?.get(0))
        log.info("JSON-RPC 2.0 === connect get Connections ---------- end")
//                return JSON.toJSONString(connResponseForApp)?.split("\",\"stream")?.get(0)
        return connResponseForApp
    }

    override fun connect2(@JsonRpcParam("data") data: ConnRequestOfApp.ConnParamsOfApp.Data?): Any? {
        return "connect2" + JSON.toJSONString(data)
    }

    override fun connect3(@JsonRpcParam("sign") sign: String?): Any? {
        return "connect3" + sign
    }

    override fun connect4(@JsonRpcParam("data") data: String?, @JsonRpcParam("sign") sign: String?): Any? {
        return "connect4" + JSON.toJSONString(data) + "-->" + sign
    }

    override fun query(queryReqBean: JSONObject?, sign: String?): Any? {
        var jsonString: String? = ""
        log.info("JSON-RPC 2.0 === connect String Information, jsonString ---------- \n{}", jsonString)
        var jsonStringChange: String? = jsonString?.split("\",\"stream")?.get(0)
        log.info("jsonStringChange === \n{}", jsonStringChange)
//        val jsonStr: JSONObject? = JSONObject.parseObject(jsonStringChange)
//        val jsonStr: JSONObject? = JSONObject.parseObject(jsonString)
//        val methodType: String? = jsonStr?.get("method") as String
        var sign: String? = "awq12m678"

        log.info("JSON-RPC 2.0 === query ---------- start")
        val queryRequestOfApp: QueryRequestOfApp = JSONObject.parseObject(jsonStringChange, QueryRequestOfApp::class.java)
        val data: QueryRequestOfApp.QueryParamsOfApp.Data? = queryRequestOfApp.params?.data
        val userInfo: QueryRequestOfApp.QueryParamsOfApp.Data.UserInfo? = queryRequestOfApp.params?.data?.userInfo
        val dataObjId: String? = queryRequestOfApp.params?.data?.dataObjId
        val sourceId: String? = queryRequestOfApp.params?.data?.source?.sourceId
        val page: QueryRequestOfApp.QueryParamsOfApp.Data.Page? = queryRequestOfApp.params?.data?.page

        log.info("JSON-RPC 2.0 === query JSONObject ---------- \n{}", JSON.toJSONString(queryRequestOfApp))

        /*
        if(APP_ID != data?.appId) {
            var dataResponse: QueryResponseForApp.QueryResultForApp.Data = QueryResponseForApp.QueryResultForApp.Data(source, arrayListOf())
            var page: QueryResponseForApp.QueryResultForApp.Page = QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, 0)
            var result: QueryResponseForApp.QueryResultForApp = QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, "3", "无效会话", "sign")
            return QueryResponseForApp().QueryResponseForApp(result)
        }
        */

        if ("police" == dataObjId) {//
            log.info("JSON-RPC 2.0 === query ---------- police")
            log.info("JSON-RPC 2.0 === query ---------- police replace the login")

            val taSession = TaSession()
            log.info("JSON-RPC 2.0 === query ---------- police replace insert session_key \n {}", "f534ceba2920499d9511ddd1055e8196")

            var police_number: String = (userInfo?.extAttr)?.get("police_number") as String
            var password: String = (userInfo?.extAttr)?.get("password") as String
            var login_type: Int? = (userInfo?.extAttr)?.get("login_type") as Int
            var resultTo: ResultTo = loginController.login(police_number, password, login_type)

            var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? = arrayListOf()
            var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
            var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("data", JSON.toJSONString(resultTo), 0, "")
            fieldValuesList?.add(fieldValuesId)
            fieldValuesList?.add(fieldValuesData)
            var dataResponse: QueryResponseForApp.QueryResultForApp.Data = QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
            var page: QueryResponseForApp.QueryResultForApp.Page = QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, 0)
            var result: QueryResponseForApp.QueryResultForApp = QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")
            var queryResponseForApp: QueryResponseForApp = QueryResponseForApp()

            queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
            queryResponseForApp.id = queryRequestOfApp.id.toString()
            queryResponseForApp.result = result

            log.info("JSON-RPC 2.0 === query ---------- police replace return result \n {}", JSON.toJSONString(queryResponseForApp))
            log.info("JSON-RPC 2.0 === query ---------- police replace return result2 \n {}", JSON.toJSONString(queryResponseForApp)?.split("\",\"stream")?.get(0))
//                    return JSON.toJSONString(queryResponseForApp)?.split("\",\"stream")?.get(0)
            return queryResponseForApp
        }
        if ("rpc" == dataObjId) {// /app/report/list
            log.info("JSON-RPC 2.0 === query ---------- rpc")
            log.info("JSON-RPC 2.0 === query ---------- accidentReportList")
            var map = hashMapOf<String, Any>()
            userInfo?.extAttr?.forEach { t, u -> if (u != null) map[t] = u }
            var resultTo: ResultTo = taAppAccidentReportController.listRpc(map, page?.pageNo, page?.pageSize)

            var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? = arrayListOf()
            var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
            var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("data", JSON.toJSONString(resultTo), 0, "")
            fieldValuesList?.add(fieldValuesId)
            fieldValuesList?.add(fieldValuesData)
            var dataResponse: QueryResponseForApp.QueryResultForApp.Data = QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
            var page: QueryResponseForApp.QueryResultForApp.Page = QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, ((resultTo["report_list"] as ArrayList<Any?>).size).toLong())
            var result: QueryResponseForApp.QueryResultForApp = QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")
            var queryResponseForApp: QueryResponseForApp = QueryResponseForApp()

            queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
            queryResponseForApp.id = queryRequestOfApp.id.toString()
            queryResponseForApp.result = result
            return QueryResponseForApp().QueryResponseForApp(queryResponseForApp)
        }

        if ("accidentReportList" == dataObjId) {//
            log.info("JSON-RPC 2.0 === query ---------- accidentReportList")
            var map = hashMapOf<String, Any>()
            userInfo?.extAttr?.forEach { t, u -> if (u != null) map[t] = u }
            var resultTo: ResultTo = taAppAccidentReportController.listRpc(map, page?.pageNo, page?.pageSize)

            var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? = arrayListOf()
            var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
            var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("data", JSON.toJSONString(resultTo), 0, "")
            fieldValuesList?.add(fieldValuesId)
            fieldValuesList?.add(fieldValuesData)
            var dataResponse: QueryResponseForApp.QueryResultForApp.Data = QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
            var page: QueryResponseForApp.QueryResultForApp.Page = QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, ((resultTo["report_list"] as ArrayList<Any?>).size).toLong())
            var result: QueryResponseForApp.QueryResultForApp = QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")
            var queryResponseForApp: QueryResponseForApp = QueryResponseForApp()

            queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
            queryResponseForApp.id = queryRequestOfApp.id.toString()
            queryResponseForApp.result = result
            return QueryResponseForApp().QueryResponseForApp(queryResponseForApp)
        }

        if ("accidentReportDetail" == dataObjId) {// /app/report/detail
            log.info("JSON-RPC 2.0 === query ---------- accidentReportDetail")
            var id: Int = (userInfo?.extAttr)?.get("id") as Int
            var resultTo: ResultTo = taAppAccidentReportController.detail(id)

            var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? = arrayListOf()
            var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
            var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("data", JSON.toJSONString(resultTo), 0, "")
            fieldValuesList?.add(fieldValuesId)
            fieldValuesList?.add(fieldValuesData)
            var dataResponse: QueryResponseForApp.QueryResultForApp.Data = QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
            var page: QueryResponseForApp.QueryResultForApp.Page = QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, ((arrayListOf(resultTo)).size).toLong())
            var result: QueryResponseForApp.QueryResultForApp = QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")
            var queryResponseForApp: QueryResponseForApp = QueryResponseForApp()

            queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
            queryResponseForApp.id = queryRequestOfApp.id.toString()
            queryResponseForApp.result = result
            return QueryResponseForApp().QueryResponseForApp(queryResponseForApp)
        }

        if ("accidentReportByReportId" == dataObjId) {// val APP_REPORT = ""       // 原/app/report/{reportId}
            log.info("JSON-RPC 2.0 === query ---------- accidentReportByReportId")
            var reportId: Int = (userInfo?.extAttr)?.get("reportId") as Int
            var resultTo: ResultTo = taAppAccidentReportController.correlation(reportId)

            var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? = arrayListOf()
            var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
            var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("data", JSON.toJSONString(resultTo), 0, "")
            fieldValuesList?.add(fieldValuesId)
            fieldValuesList?.add(fieldValuesData)
            var dataResponse: QueryResponseForApp.QueryResultForApp.Data = QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
            var page: QueryResponseForApp.QueryResultForApp.Page = QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, 1)
            var result: QueryResponseForApp.QueryResultForApp = QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")
            var queryResponseForApp: QueryResponseForApp = QueryResponseForApp()

            queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
            queryResponseForApp.id = queryRequestOfApp.id.toString()
            queryResponseForApp.result = result
            return QueryResponseForApp().QueryResponseForApp(queryResponseForApp)
        }

        if ("accidentReportByReportIdAndOracleId" == dataObjId) {// val APP_REPORT_BIND = ""  // 原/app/report/{reportId}/{oracleId}
            log.info("JSON-RPC 2.0 === query ---------- accidentReportByReportIdAndOracleId")
            var reportId: Int = (userInfo?.extAttr)?.get("reportId") as Int
            var djbh: String = (userInfo?.extAttr)?.get("djbh") as String
            var resultTo: ResultTo = taAppAccidentReportController.checkCorrelation(reportId, djbh)

            var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? = arrayListOf()
            var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
            var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("data", JSON.toJSONString(resultTo), 0, "")
            fieldValuesList?.add(fieldValuesId)
            fieldValuesList?.add(fieldValuesData)
            var dataResponse: QueryResponseForApp.QueryResultForApp.Data = QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
            var page: QueryResponseForApp.QueryResultForApp.Page = QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, 1)
            var result: QueryResponseForApp.QueryResultForApp = QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")
            var queryResponseForApp: QueryResponseForApp = QueryResponseForApp()

            queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
            queryResponseForApp.id = queryRequestOfApp.id.toString()
            queryResponseForApp.result = result
            return QueryResponseForApp().QueryResponseForApp(queryResponseForApp)
        }

        if ("accidentReportByOracleId" == dataObjId) {// val APP_REPORT_BIND = ""  // 原/app/report/{reportId}/{oracleId}
            log.info("JSON-RPC 2.0 === query ---------- accidentReportByOracleId")
            var djbh: String = (userInfo?.extAttr)?.get("djbh") as String
            var resultTo: ResultTo = taAppAccidentReportController.selectOracleById(djbh)

            var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? = arrayListOf()
            var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
            var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("data", JSON.toJSONString(resultTo), 0, "")
            fieldValuesList?.add(fieldValuesId)
            fieldValuesList?.add(fieldValuesData)
            var dataResponse: QueryResponseForApp.QueryResultForApp.Data = QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
            var page: QueryResponseForApp.QueryResultForApp.Page = QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, 1)
            var result: QueryResponseForApp.QueryResultForApp = QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")
            var queryResponseForApp: QueryResponseForApp = QueryResponseForApp()

            queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
            queryResponseForApp.id = queryRequestOfApp.id.toString()
            queryResponseForApp.result = result
            return QueryResponseForApp().QueryResponseForApp(queryResponseForApp)
        }

        if ("selectForwardLog" == dataObjId) {// /admin/report/selectForwardLog
            log.info("JSON-RPC 2.0 === query ---------- selectForwardLog")
            var accident_report_id: Int = (userInfo?.extAttr)?.get("accident_report_id") as Int
            var resultTo: ResultTo = taAccidentReportController.selectForwardLog(accident_report_id)

            var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? = arrayListOf()
            var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
            var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("data", JSON.toJSONString(resultTo), 0, "")
            fieldValuesList?.add(fieldValuesId)
            fieldValuesList?.add(fieldValuesData)
            var dataResponse: QueryResponseForApp.QueryResultForApp.Data = QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
            var page: QueryResponseForApp.QueryResultForApp.Page = QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, ((resultTo["forwardLog"] as ArrayList<Any?>).size).toLong())
            var result: QueryResponseForApp.QueryResultForApp = QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")
            var queryResponseForApp: QueryResponseForApp = QueryResponseForApp()

            queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
            queryResponseForApp.id = queryRequestOfApp.id.toString()
            queryResponseForApp.result = result
            return QueryResponseForApp().QueryResponseForApp(queryResponseForApp)
        }

        if ("forwardPoliceList" == dataObjId) {// /app/accident/forward_list/
            log.info("JSON-RPC 2.0 === query ---------- forwardPoliceList")
            var name: String? = (userInfo?.extAttr)?.get("name") as String
            var resultTo: ResultTo = taAppAccidentController.forwardPoliceList(name)
//                    var resultTo: ResultTo = taAppAccidentController.forwardPoliceList(userInfo?.userId)

            var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? = arrayListOf()
            var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
            var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("data", JSON.toJSONString(resultTo), 0, "")
            fieldValuesList?.add(fieldValuesId)
            fieldValuesList?.add(fieldValuesData)
            var dataResponse: QueryResponseForApp.QueryResultForApp.Data = QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
            var page: QueryResponseForApp.QueryResultForApp.Page = QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, ((resultTo["policeList"] as ArrayList<Any?>).size).toLong())
            var result: QueryResponseForApp.QueryResultForApp = QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")
            var queryResponseForApp: QueryResponseForApp = QueryResponseForApp()

            queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
            queryResponseForApp.id = queryRequestOfApp.id.toString()
            queryResponseForApp.result = result
            return QueryResponseForApp().QueryResponseForApp(queryResponseForApp)
        }

        if ("getMqMsg" == dataObjId) {// /app/accident/getMqMsg
            log.info("JSON-RPC 2.0 === query ---------- getMqMsg")
            var police_number: String = (userInfo?.extAttr)?.get("police_number") as String
            var resultTo: ResultTo = taAppAccidentController.getMqMsg(police_number) as ResultTo

            var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? = arrayListOf()
            var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
            var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("data", JSON.toJSONString(resultTo), 0, "")
            fieldValuesList?.add(fieldValuesId)
            fieldValuesList?.add(fieldValuesData)
            var dataResponse: QueryResponseForApp.QueryResultForApp.Data = QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
            var page: QueryResponseForApp.QueryResultForApp.Page = QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, ((resultTo["taHmsPushList"] as ArrayList<Any?>).size).toLong())
            var result: QueryResponseForApp.QueryResultForApp = QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")
            var queryResponseForApp: QueryResponseForApp = QueryResponseForApp()

            queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
            queryResponseForApp.id = queryRequestOfApp.id.toString()
            queryResponseForApp.result = result
            return QueryResponseForApp().QueryResponseForApp(queryResponseForApp)
        }

        if ("login" == dataObjId) {// /police/login
            log.info("JSON-RPC 2.0 === query ---------- login")
            var police_number: String = (userInfo?.extAttr)?.get("police_number") as String
            var password: String = (userInfo?.extAttr)?.get("password") as String
            var login_type: Int? = (userInfo?.extAttr)?.get("login_type") as Int
            var resultTo: ResultTo = loginController.login(police_number, password, login_type)

            var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? = arrayListOf()
            var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
            var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("data", JSON.toJSONString(resultTo), 0, "")
            fieldValuesList?.add(fieldValuesId)
            fieldValuesList?.add(fieldValuesData)
            var dataResponse: QueryResponseForApp.QueryResultForApp.Data = QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
            var page: QueryResponseForApp.QueryResultForApp.Page = QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, 0)
            var result: QueryResponseForApp.QueryResultForApp = QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")
            var queryResponseForApp: QueryResponseForApp = QueryResponseForApp()

            queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
            queryResponseForApp.id = queryRequestOfApp.id.toString()
            queryResponseForApp.result = result
            return QueryResponseForApp().QueryResponseForApp(queryResponseForApp)
        }

        if ("logout" == dataObjId) {// /police/logout
            log.info("JSON-RPC 2.0 === query ---------- logout")
            var session_key: String = (userInfo?.extAttr)?.get("session_key") as String
            var resultTo: ResultTo = loginController.logout(session_key)

            var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? = arrayListOf()
            var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
            var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("data", JSON.toJSONString(resultTo), 0, "")
            fieldValuesList?.add(fieldValuesId)
            fieldValuesList?.add(fieldValuesData)
            var dataResponse: QueryResponseForApp.QueryResultForApp.Data = QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
            var page: QueryResponseForApp.QueryResultForApp.Page = QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, 0)
            var result: QueryResponseForApp.QueryResultForApp = QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")
            var queryResponseForApp: QueryResponseForApp = QueryResponseForApp()

            queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
            queryResponseForApp.id = queryRequestOfApp.id.toString()
            queryResponseForApp.result = result
            return QueryResponseForApp().QueryResponseForApp(queryResponseForApp)
        }

        if ("isLogin" == dataObjId) {// /police/isLogin
            log.info("JSON-RPC 2.0 === query ---------- isLogin")
            var resultTo: ResultTo = loginController.logout()

            var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? = arrayListOf()
            var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
            var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("data", JSON.toJSONString(resultTo), 0, "")
            fieldValuesList?.add(fieldValuesId)
            fieldValuesList?.add(fieldValuesData)
            var dataResponse: QueryResponseForApp.QueryResultForApp.Data = QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
            var page: QueryResponseForApp.QueryResultForApp.Page = QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, 0)
            var result: QueryResponseForApp.QueryResultForApp = QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")
            var queryResponseForApp: QueryResponseForApp = QueryResponseForApp()

            queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
            queryResponseForApp.id = queryRequestOfApp.id.toString()
            queryResponseForApp.result = result
            return QueryResponseForApp().QueryResponseForApp(queryResponseForApp)
        }

        /*
         * 统一认证票据验证接口
         * 1.验证结果flag：0验证通过，1票据信息过期，2票据信息验证未通过，3该票据信息不属于平台发放票据，4其它错误。
         * 待定 20201224
         * result_20201225: 弃用
         *      统一认证服务接口不需进行JSON-RPC数据服务包装
         */
        if ("verifyBillUnify" == dataObjId) {// /
            log.info("JSON-RPC 2.0 === query ---------- verifyBillUnify")
            var strBill: String = (userInfo?.extAttr)?.get("strBill") as String
            var resultVeriry = loginController.verifyBillUnify(strBill)
            return resultVeriry
        }

        if ("roadManagerList" == dataObjId) {// /admin/roadManager/list
            log.info("JSON-RPC 2.0 === query ---------- roadManagerList")
            var roadName: String? = (userInfo?.extAttr)?.get("roadName") as String
            var createTime_begin: String? = (userInfo?.extAttr)?.get("createTime_begin") as String
            var createTime_end: String? = (userInfo?.extAttr)?.get("createTime_end") as String
            var resultTo: ResultTo = roadRepairController.listRpc(hashMapOf<String, Any>(), roadName, createTime_begin, createTime_end)

            var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? = arrayListOf()
            var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
            var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("data", JSON.toJSONString(resultTo), 0, "")
            fieldValuesList?.add(fieldValuesId)
            fieldValuesList?.add(fieldValuesData)
            var dataResponse: QueryResponseForApp.QueryResultForApp.Data = QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
            var page: QueryResponseForApp.QueryResultForApp.Page = QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, ((resultTo["road_list"] as ArrayList<Any?>).size).toLong())
            var result: QueryResponseForApp.QueryResultForApp = QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")
            var queryResponseForApp: QueryResponseForApp = QueryResponseForApp()

            queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
            queryResponseForApp.id = queryRequestOfApp.id.toString()
            queryResponseForApp.result = result
            return QueryResponseForApp().QueryResponseForApp(queryResponseForApp)
        }

//                TaAppAccidentStatisticsController
        if ("accidentMapAll" == dataObjId) {// /app/statistics/accident_map_all
            log.info("JSON-RPC 2.0 === query ---------- accidentMapAll")
            var start_time: Date = (userInfo?.extAttr)?.get("start_time") as Date
            var end_time: Date = (userInfo?.extAttr)?.get("end_time") as Date
            var resultTo: ResultTo = taAppAccidentStatisticsController.accidentMapAll(start_time, end_time)

            var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? = arrayListOf()
            var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
            var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("data", JSON.toJSONString(resultTo), 0, "")
            fieldValuesList?.add(fieldValuesId)
            fieldValuesList?.add(fieldValuesData)
            var dataResponse: QueryResponseForApp.QueryResultForApp.Data = QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
            var page: QueryResponseForApp.QueryResultForApp.Page = QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, ((resultTo["data"] as ArrayList<Any?>).size).toLong())
            var result: QueryResponseForApp.QueryResultForApp = QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")
            var queryResponseForApp: QueryResponseForApp = QueryResponseForApp()

            queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
            queryResponseForApp.id = queryRequestOfApp.id.toString()
            queryResponseForApp.result = result
            return QueryResponseForApp().QueryResponseForApp(queryResponseForApp)
        }

        if ("expMsgSelectAll" == dataObjId) {// /app/exp_msg/
            log.info("JSON-RPC 2.0 === query ---------- expMsgSelectAll")
            var resultTo: ResultTo = taAppExceptionMsgController.selectAll()

            var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? = arrayListOf()
            var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
            var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("data", JSON.toJSONString(resultTo), 0, "")
            fieldValuesList?.add(fieldValuesId)
            fieldValuesList?.add(fieldValuesData)
            var dataResponse: QueryResponseForApp.QueryResultForApp.Data = QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
            var page: QueryResponseForApp.QueryResultForApp.Page = QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, ((resultTo["data"] as ArrayList<Any?>).size).toLong())
            var result: QueryResponseForApp.QueryResultForApp = QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")
            var queryResponseForApp: QueryResponseForApp = QueryResponseForApp()

            queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
            queryResponseForApp.id = queryRequestOfApp.id.toString()
            queryResponseForApp.result = result
            return QueryResponseForApp().QueryResponseForApp(queryResponseForApp)
        }

        if ("locationReportSelectByNum" == dataObjId) {// /app/location_report/
            log.info("JSON-RPC 2.0 === query ---------- locationReportSelectByNum")
            var police_number: String = (userInfo?.extAttr)?.get("police_number") as String
            var resultTo: ResultTo = taLocationReportController.selectByNum(police_number)

            var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? = arrayListOf()
            var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
            var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("data", JSON.toJSONString(resultTo), 0, "")
            fieldValuesList?.add(fieldValuesId)
            fieldValuesList?.add(fieldValuesData)
            var dataResponse: QueryResponseForApp.QueryResultForApp.Data = QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
            var page: QueryResponseForApp.QueryResultForApp.Page = QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, ((resultTo["data"] as ArrayList<Any?>).size).toLong())
            var result: QueryResponseForApp.QueryResultForApp = QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")
            var queryResponseForApp: QueryResponseForApp = QueryResponseForApp()

            queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
            queryResponseForApp.id = queryRequestOfApp.id.toString()
            queryResponseForApp.result = result
            return QueryResponseForApp().QueryResponseForApp(queryResponseForApp)
        }

        if ("accidentMapType" == dataObjId) {// /app/statistics/type
        }
        if ("accidentMapAllDealType" == dataObjId) {// /app/statistics/deal-type
        }
        if ("accidentMapSection" == dataObjId) {// /app/statistics/section
        }
        if ("accidentMapAllCaseHour" == dataObjId) {// /app/statistics/case-hour
        }

        if ("accidentMapOld" == dataObjId) {// /app/statistics/accident_map_old
            log.info("JSON-RPC 2.0 === query ---------- accidentMapOld")
            var start_time: Date = (userInfo?.extAttr)?.get("start_time") as Date
            var end_time: Date = (userInfo?.extAttr)?.get("end_time") as Date
            var resultTo: ResultTo = taAppAccidentStatisticsController.accidentMapOld(start_time, end_time)

            var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? = arrayListOf()
            var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
            var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("data", JSON.toJSONString(resultTo), 0, "")
            fieldValuesList?.add(fieldValuesId)
            fieldValuesList?.add(fieldValuesData)
            var dataResponse: QueryResponseForApp.QueryResultForApp.Data = QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
            var page: QueryResponseForApp.QueryResultForApp.Page = QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, ((resultTo["data"] as ArrayList<Any?>).size).toLong())
            var result: QueryResponseForApp.QueryResultForApp = QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")
            var queryResponseForApp: QueryResponseForApp = QueryResponseForApp()

            queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
            queryResponseForApp.id = queryRequestOfApp.id.toString()
            queryResponseForApp.result = result
            return QueryResponseForApp().QueryResponseForApp(queryResponseForApp)
        }

        if ("apiAccident" == dataObjId) {// /api/statistics/accident/
            log.info("JSON-RPC 2.0 === query ---------- apiAccident")
            var start_time: Date = (userInfo?.extAttr)?.get("start_time") as Date
            var end_time: Date = (userInfo?.extAttr)?.get("end_time") as Date
            var deathStart: Int = (userInfo?.extAttr)?.get("deathStart") as Int
            var deathEnd: Int = (userInfo?.extAttr)?.get("deathEnd") as Int
            var resultTo: ResultTo = statisticsController.generalAccident(start_time, end_time, deathStart, deathEnd)

            var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? = arrayListOf()
            var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
            var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues = QueryResponseForApp.QueryResultForApp.Data.FieldValues("data", JSON.toJSONString(resultTo), 0, "")
            fieldValuesList?.add(fieldValuesId)
            fieldValuesList?.add(fieldValuesData)
            var dataResponse: QueryResponseForApp.QueryResultForApp.Data = QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
            var page: QueryResponseForApp.QueryResultForApp.Page = QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, 1)
            var result: QueryResponseForApp.QueryResultForApp = QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")
            var queryResponseForApp: QueryResponseForApp = QueryResponseForApp()

            queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
            queryResponseForApp.id = queryRequestOfApp.id.toString()
            queryResponseForApp.result = result
            return QueryResponseForApp().QueryResponseForApp(queryResponseForApp)
        }

        return "query" + JSON.toJSONString(queryReqBean)
    }

    override fun operate(queryReqBean: String?): Any? {
        var jsonString: String? = ""
        log.info("JSON-RPC 2.0 === connect String Information, jsonString ---------- \n{}", jsonString)
        var jsonStringChange: String? = jsonString?.split("\",\"stream")?.get(0)
        log.info("jsonStringChange === \n{}", jsonStringChange)
        val jsonStr: JSONObject? = JSONObject.parseObject(jsonStringChange)
//        val jsonStr: JSONObject? = JSONObject.parseObject(jsonString)
        val methodType: String? = jsonStr?.get("method") as String
        var sign: String? = "awq12m678"

        log.info("JSON-RPC 2.0 === operate ---------- start")
        var operateResponseForApp: OperateResponseForApp = OperateResponseForApp()
        var operationListResponse: ArrayList<OperateResponseForApp.OperateResultForApp.Operation> = arrayListOf()

        var operateRequestOfApp: OperateRequestOfApp = JSONObject.parseObject(jsonStringChange, OperateRequestOfApp::class.java)
        var params: OperateRequestOfApp.OperateParamsOfApp? = operateRequestOfApp?.params
        var data: OperateRequestOfApp.OperateParamsOfApp.Data? = params?.data
        var userInfo: OperateRequestOfApp.OperateParamsOfApp.Data.UserInfo? = data?.userInfo
        var operations: ArrayList<OperateRequestOfApp.OperateParamsOfApp.Data.Operation>? = data?.operations

        log.info("JSON-RPC 2.0 === operate JSONObject ---------- \n{}", JSON.toJSONString(operateRequestOfApp))

        if (operations != null && operations.size > 0) {
            operations?.forEach { it ->

                var operationType: Int? = it.operationType
                var operationId: String? = it.operationId
                var sourceId: String? = it.sourceId
                var dataObjId: String? = it.dataObjId
                var condition: String? = it.condition
                var dataListOfOperation: ArrayList<OperateRequestOfApp.OperateParamsOfApp.Data.Operation.Data>? = it?.data

                if ("policeAccept" == dataObjId) {// /app/accident/police_accept
                    log.info("JSON-RPC 2.0 === operate ---------- policeAccept")
                    dataListOfOperation?.forEach { d ->
                        var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                        var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                        fieldValues?.forEach { f ->
                            fieldValuesMap.put(f["field"] as String, f["value"])
                        }
                        var fieldValuesJSON: JSONObject = JSONObject.toJSON(fieldValuesMap) as JSONObject
                        var has_accepted: Int = fieldValuesMap["has_accepted"] as Int
                        var accident_report_id: Int = fieldValuesMap["accident_report_id"] as Int
                        var resultTo: ResultTo = taAppAccidentController.policeAccept(has_accepted, accident_report_id)

                        var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                        operationMessageMap?.put("message", resultTo["err_message"])

                        var operationResponse: OperateResponseForApp.OperateResultForApp.Operation = OperateResponseForApp.OperateResultForApp.Operation(
                                operationId as String,
                                if (0 == resultTo["err_code"] as Int) "1" else "2",
                                /*resultTo["err_message"] as String,*/
                                JSON.toJSONString(operationMessageMap),
                                1
                        )
                        operationListResponse.add(operationResponse)
                    }
                }

                if ("policeForward" == dataObjId) {// /app/accident/forward_report/
                    log.info("JSON-RPC 2.0 === operate ---------- policeForward")
                    dataListOfOperation?.forEach { d ->
                        var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                        var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                        fieldValues?.forEach { f ->
                            fieldValuesMap.put(f["field"] as String, f["value"])
                        }
                        var fieldValuesJSON: JSONObject = JSONObject.toJSON(fieldValuesMap) as JSONObject
                        var police_number: String = fieldValuesMap["police_number"] as String
                        var accident_report_id: Int = fieldValuesMap["accident_report_id"] as Int
                        var resultTo: ResultTo = taAppAccidentController.policeForward(police_number, police_number, accident_report_id)

                        var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                        operationMessageMap?.put("message", resultTo["err_message"])

                        var operationResponse: OperateResponseForApp.OperateResultForApp.Operation = OperateResponseForApp.OperateResultForApp.Operation(
                                operationId as String,
                                if (0 == resultTo["err_code"] as Int) "1" else "2",
                                /*resultTo["err_message"] as String,*/
                                JSON.toJSONString(operationMessageMap),
                                1
                        )
                        operationListResponse.add(operationResponse)
                    }
                }

                if ("policeAddReport" == dataObjId) {// /app/accident/police_add_report
                    log.info("JSON-RPC 2.0 === operate ---------- policeAddReport")
                    dataListOfOperation?.forEach { d ->
                        var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                        var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                        fieldValues?.forEach { f ->
                            fieldValuesMap.put(f["field"] as String, f["value"])
                        }
                        var fieldValuesJSON: JSONObject = JSONObject.toJSON(fieldValuesMap) as JSONObject
                        var taAccident: TaAccident = JSONObject.parseObject(JSON.toJSONString(fieldValuesJSON), TaAccident::class.java)
                        var resultTo: ResultTo = taAppAccidentController.policeAddReport(taAccident)
                        var taAccidentId: Int? = resultTo?.get("taAccidentId") as Int

                        var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                        operationMessageMap?.put("message", resultTo["err_message"])
                        operationMessageMap?.put("taAccidentId", taAccidentId)

                        var operationResponse: OperateResponseForApp.OperateResultForApp.Operation = OperateResponseForApp.OperateResultForApp.Operation(
                                operationId as String,
                                if (0 == resultTo["err_code"] as Int) "1" else "2",
                                JSON.toJSONString(operationMessageMap),
                                1
                        )
                        operationListResponse.add(operationResponse)
                    }
                }

                if ("policeAddReportImage" == dataObjId) {// /app/accident/upload_image
                    log.info("JSON-RPC 2.0 === operate ---------- policeAddReportImage")
                    dataListOfOperation?.forEach { d ->
                        var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                        var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                        fieldValues?.forEach { f ->
                            fieldValuesMap.put(f["field"] as String, f["value"])
                        }
                        var fieldValuesJSON: JSONObject = JSONObject.toJSON(fieldValuesMap) as JSONObject
                        var taAccidentImage: TaAccidentImage = JSONObject.parseObject(JSON.toJSONString(fieldValuesJSON), TaAccidentImage::class.java)
                        var resultTo: ResultTo = taAppAccidentController.policeAddReportImage(taAccidentImage)

                        var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                        operationMessageMap?.put("message", resultTo["err_message"])

                        var operationResponse: OperateResponseForApp.OperateResultForApp.Operation = OperateResponseForApp.OperateResultForApp.Operation(
                                operationId as String,
                                if (0 == resultTo["err_code"] as Int) "1" else "2",
                                /*resultTo["err_message"] as String,*/
                                JSON.toJSONString(operationMessageMap),
                                1
                        )
                        operationListResponse.add(operationResponse)
                    }
                }

                if ("policeEdit" == dataObjId) {// /admin/police/edit
                    log.info("JSON-RPC 2.0 === operate ---------- policeEdit")
                    dataListOfOperation?.forEach { d ->
                        var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                        var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                        fieldValues?.forEach { f ->
                            fieldValuesMap.put(f["field"] as String, f["value"])
                        }
                        var fieldValuesJSON: JSONObject = JSONObject.toJSON(fieldValuesMap) as JSONObject
                        var taPoliceVo: TaPoliceVo = JSONObject.parseObject(JSON.toJSONString(fieldValuesJSON), TaPoliceVo::class.java)
                        var resultTo: ResultTo = taPoliceController.edit(taPoliceVo)

                        var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                        operationMessageMap?.put("message", resultTo["err_message"])

                        var operationResponse: OperateResponseForApp.OperateResultForApp.Operation = OperateResponseForApp.OperateResultForApp.Operation(
                                operationId as String,
                                if (0 == resultTo["err_code"] as Int) "1" else "2",
                                /*resultTo["err_message"] as String,*/
                                JSON.toJSONString(operationMessageMap),
                                1
                        )
                        operationListResponse.add(operationResponse)
                    }
                }

                if ("roadManagerUploadOneImg" == dataObjId) {// /admin/roadManager/uploadOneImg
                    log.info("JSON-RPC 2.0 === operate ---------- roadManagerUploadOneImg")
                    dataListOfOperation?.forEach { d ->
                        var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                        var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                        var fieldValuesMapCovert: HashMap<String, String> = hashMapOf()
                        fieldValues?.forEach { f ->
                            fieldValuesMap.put(f["field"] as String, f["value"])
                            fieldValuesMapCovert.put(f["field"] as String, f["value"] as String)
                        }
                        var resultTo: ResultTo = roadRepairController.uploadOneImg(fieldValuesMapCovert)

                        var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                        operationMessageMap?.put("message", resultTo["err_message"])

                        var operationResponse: OperateResponseForApp.OperateResultForApp.Operation = OperateResponseForApp.OperateResultForApp.Operation(
                                operationId as String,
                                if (0 == resultTo["err_code"] as Int) "1" else "2",
                                /*resultTo["err_message"] as String,*/
                                JSON.toJSONString(operationMessageMap),
                                1
                        )
                        operationListResponse.add(operationResponse)
                    }
                }

                if ("roadManagerAdd" == dataObjId) {// /admin/roadManager/add
                    log.info("JSON-RPC 2.0 === operate ---------- roadManagerAdd")
                    dataListOfOperation?.forEach { d ->
                        var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                        var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                        fieldValues?.forEach { f ->
                            fieldValuesMap.put(f["field"] as String, f["value"])
                        }
                        var fieldValuesJSON: JSONObject = JSONObject.toJSON(fieldValuesMap) as JSONObject
                        var taRoadRepair: TaRoadRepair = JSONObject.parseObject(JSON.toJSONString(fieldValuesJSON), TaRoadRepair::class.java)
                        var resultTo: ResultTo = roadRepairController.add(taRoadRepair)

                        var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                        operationMessageMap?.put("message", resultTo["err_message"])

                        var operationResponse: OperateResponseForApp.OperateResultForApp.Operation = OperateResponseForApp.OperateResultForApp.Operation(
                                operationId as String,
                                if (0 == resultTo["err_code"] as Int) "1" else "2",
                                /*resultTo["err_message"] as String,*/
                                JSON.toJSONString(operationMessageMap),
                                1
                        )
                        operationListResponse.add(operationResponse)
                    }
                }

                if ("roadManagerEdit" == dataObjId) {// /admin/roadManager/edit
                    log.info("JSON-RPC 2.0 === operate ---------- roadManagerEdit")
                    dataListOfOperation?.forEach { d ->
                        var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                        var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                        fieldValues?.forEach { f ->
                            fieldValuesMap.put(f["field"] as String, f["value"])
                        }
                        var fieldValuesJSON: JSONObject = JSONObject.toJSON(fieldValuesMap) as JSONObject
                        var taRoadRepair: TaRoadRepair = JSONObject.parseObject(JSON.toJSONString(fieldValuesJSON), TaRoadRepair::class.java)
                        var resultTo: ResultTo = roadRepairController.edit(taRoadRepair)

                        var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                        operationMessageMap?.put("message", resultTo["err_message"])

                        var operationResponse: OperateResponseForApp.OperateResultForApp.Operation = OperateResponseForApp.OperateResultForApp.Operation(
                                operationId as String,
                                if (0 == resultTo["err_code"] as Int) "1" else "2",
                                /*resultTo["err_message"] as String,*/
                                JSON.toJSONString(operationMessageMap),
                                1
                        )
                        operationListResponse.add(operationResponse)
                    }
                }

                if ("expMsgSelectInsert" == dataObjId) {// /app/exp_msg/
                    log.info("JSON-RPC 2.0 === operate ---------- expMsgSelectInsert")
                    dataListOfOperation?.forEach { d ->
                        var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                        var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                        fieldValues?.forEach { f ->
                            fieldValuesMap.put(f["field"] as String, f["value"])
                        }
                        var fieldValuesJSON: JSONObject = JSONObject.toJSON(fieldValuesMap) as JSONObject
                        var taAppExceptionMsg: TaAppExceptionMsg = JSONObject.parseObject(JSON.toJSONString(fieldValuesJSON), TaAppExceptionMsg::class.java)
                        var resultTo: ResultTo = taAppExceptionMsgController.insert(taAppExceptionMsg)

                        var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                        operationMessageMap?.put("message", resultTo["err_message"])

                        var operationResponse: OperateResponseForApp.OperateResultForApp.Operation = OperateResponseForApp.OperateResultForApp.Operation(
                                operationId as String,
                                if (0 == resultTo["err_code"] as Int) "1" else "2",
                                /*resultTo["err_message"] as String,*/
                                JSON.toJSONString(operationMessageMap),
                                1
                        )
                        operationListResponse.add(operationResponse)
                    }
                }

                if ("locationReportInsert" == dataObjId) {// /app/location_report/
                    log.info("JSON-RPC 2.0 === operate ---------- locationReportInsert")
                    dataListOfOperation?.forEach { d ->
                        var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                        var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                        fieldValues?.forEach { f ->
                            fieldValuesMap.put(f["field"] as String, f["value"])
                        }
                        var fieldValuesJSON: JSONObject = JSONObject.toJSON(fieldValuesMap) as JSONObject
                        var taLocationReport: TaLocationReport = JSONObject.parseObject(JSON.toJSONString(fieldValuesJSON), TaLocationReport::class.java)
                        var resultTo: ResultTo = taLocationReportController.insert(taLocationReport)

                        var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                        operationMessageMap?.put("message", resultTo["err_message"])

                        var operationResponse: OperateResponseForApp.OperateResultForApp.Operation = OperateResponseForApp.OperateResultForApp.Operation(
                                operationId as String,
                                if (0 == resultTo["err_code"] as Int) "1" else "2",
                                /*resultTo["err_message"] as String,*/
                                JSON.toJSONString(operationMessageMap),
                                1
                        )
                        operationListResponse.add(operationResponse)
                    }
                }

                if ("imageInsert" == dataObjId) {// /app/image/
                    log.info("JSON-RPC 2.0 === operate ---------- imageInsert")
                    dataListOfOperation?.forEach { d ->
                        var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                        var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                        fieldValues?.forEach { f ->
                            fieldValuesMap.put(f["field"] as String, f["value"])
                        }
                        var fieldValuesJSON: JSONObject = JSONObject.toJSON(fieldValuesMap) as JSONObject
                        var taAccidentImage: TaAccidentImage = JSONObject.parseObject(JSON.toJSONString(fieldValuesJSON), TaAccidentImage::class.java)
                        var resultTo: ResultTo = taAccidentImageController.delete(taAccidentImage)

                        var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                        operationMessageMap?.put("message", resultTo["err_message"])

                        var operationResponse: OperateResponseForApp.OperateResultForApp.Operation = OperateResponseForApp.OperateResultForApp.Operation(
                                operationId as String,
                                if (0 == resultTo["err_code"] as Int) "1" else "2",
                                /*resultTo["err_message"] as String,*/
                                JSON.toJSONString(operationMessageMap),
                                1
                        )
                        operationListResponse.add(operationResponse)
                    }
                }

                if ("imageDeleteById" == dataObjId) {// /app/image/
                    log.info("JSON-RPC 2.0 === operate ---------- imageDeleteById")
                    dataListOfOperation?.forEach { d ->
                        var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                        var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                        fieldValues?.forEach { f ->
                            fieldValuesMap.put(f["field"] as String, f["value"])
                        }
                        var id: Int = fieldValuesMap["id"] as Int
                        var resultTo: ResultTo = taAccidentImageController.delete(id)

                        var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                        operationMessageMap?.put("message", resultTo["err_message"])

                        var operationResponse: OperateResponseForApp.OperateResultForApp.Operation = OperateResponseForApp.OperateResultForApp.Operation(
                                operationId as String,
                                if (0 == resultTo["err_code"] as Int) "1" else "2",
                                /*resultTo["err_message"] as String,*/
                                JSON.toJSONString(operationMessageMap),
                                1
                        )
                        operationListResponse.add(operationResponse)
                    }
                }

            }
        }
        log.info("JSON-RPC 2.0 === operate ---------- return result \n{}", JSON.toJSONString(OperateResponseForApp().OperateResponseForApp(operationListResponse, 1, "OK")))
        return OperateResponseForApp().OperateResponseForApp(operationListResponse, 1, "OK")
    }

    override fun aques(id: String?): Any? {
        return "aques:"+ id
    }

    override fun safd(id: String?): Any? {
        return "safd:" + id
    }

    override fun bds(): Any? {
        return "Bds"
    }

    companion object {
        private val log: Logger = LoggerFactory.getLogger(this::class.java)
    }
}